<?php
class FormEditerSeance{
private $idSeance;
private $numero;
private $libelleSeance;
private $dateSeance;
private $numEp;
private $presences; // de type array()
private $idGroupe;
private $erreurs=array();

function __construct($idSeance, $numero, $libelleSeance, $dateSeance, $numEp, $presences, $idGroupe) {
    $this->idSeance = $idSeance;
    $this->numero = $numero;
    $this->libelleSeance = $libelleSeance;
    $this->dateSeance = $dateSeance;
    $this->numEp = $numEp;
    $this->presences = $presences;
    $this->idGroupe = $idGroupe;
}

public static function bind(){
    $idSeance=isset($_POST["idSeance"])?$_POST["idSeance"]:null;
    $numero=isset($_POST["numero"])?$_POST["numero"]:null;
    $libelleSeance=isset($_POST["libelleSeance"])?$_POST["libelleSeance"]:null;
    $dateSeance=isset($_POST["dateSeance"])?$_POST["dateSeance"]:null;
    $numEp=isset($_POST["numEp"])?$_POST["numEp"]:null;
    $idGroupe=isset($_POST["idGroupe"])?$_POST["idGroupe"]:null;
    $presences=isset($_POST["presences"])?$_POST["presences"]:array();// de type array()
    
    return new FormEditerSeance($idSeance, $numero, $libelleSeance, $dateSeance, $numEp, $presences,$idGroupe);    
}

public function save($bda){
    $bda->updateSeance($this->idSeance,$this->numero, $this->libelleSeance, $this->dateSeance, $this->numEp, $this->presences, $this->idGroupe);
    // sauvegarder les attributs
    // sauvegarder toutes les présences de la séance
}
public function isValid(){
    $isValid=true;
    $attributes =get_object_vars($this);
        foreach ($attributes as $key => $value) {
            if($key!="erreurs"){
                if($value==""){
                    $this->erreurs[$key]="Champs obligatoire";
                    $isValid=false;
                }
            }
        }    
    return $isValid;
}

public function getIdSeance() {
    return $this->idSeance;
}

public function setIdSeance($idSeance) {
    $this->idSeance = $idSeance;
}

public function getNumero() {
    return $this->numero;
}

public function setNumero($numero) {
    $this->numero = $numero;
}

public function getLibelleSeance() {
    return $this->libelleSeance;
}

public function setLibelleSeance($libelleSeance) {
    $this->libelleSeance = $libelleSeance;
}

public function getDateSeance() {
    return $this->dateSeance;
}

public function setDateSeance($dateSeance) {
    $this->dateSeance = $dateSeance;
}

public function getNumEp() {
    return $this->numEp;
}

public function setNumEp($numEp) {
    $this->numEp = $numEp;
}

public function getPresences() {
    return $this->presences;
}

public function setPresences($presences) {
    $this->presences = $presences;
}

public function getIdGroupe() {
    return $this->idGroupe;
}

public function setIdGroupe($idGroupe) {
    $this->idGroupe = $idGroupe;
}

public function getErreurs() {
    return $this->erreurs;
}

public function setErreurs($erreurs) {
    $this->erreurs = $erreurs;
}

public function getErreur($attribute_name) {
return isset($this->erreurs[$attribute_name])?$this->erreurs[$attribute_name]:null;
}

}
?>